﻿/******************************************************************************

    Copyright (c) 2010, Sergey Mudrov
    All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are met:
        * Redistributions of source code must retain the above copyright
          notice, this list of conditions and the following disclaimer.
        * Redistributions in binary form must reproduce the above copyright
          notice, this list of conditions and the following disclaimer in the
          documentation and/or other materials provided with the distribution.
        * Neither the name of Sergey Mudrov nor the
          names of its contributors may be used to endorse or promote products
          derived from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
    DISCLAIMED. IN NO EVENT SHALL SERGEY MUDROV BE LIABLE FOR ANY
    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*******************************************************************************/

using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using VkApi.DataTypes;

namespace VkApi
{
    /// Delegates
    /// <summary>
    /// API callback.
    /// </summary>
    public delegate void ApiCallback<T>(Response<T> response);

    /// <summary>
    /// Handler for VK initializing fail.
    /// </summary>
    public delegate void VkInitFailed_Handler(object sender, VkInitFailedEventArgs e);

    /// <summary>
    /// Handler for JSON callback.
    /// </summary>
    public delegate string CallbackJsonPreprocess_Handler(string json);

    /// <summary>
    /// Class that represents non VK initialized exception.
    /// </summary>
    /// Exceptions
    public class NotInitializedException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NotInitializedException"/> class.
        /// </summary>
        public NotInitializedException()
            : base("Vk is not initialized! Please execute 'Initialize' method before accessing any properties/methods.")
        { }

        /// <summary>
        /// Initializes a new instance of the <see cref="NotInitializedException"/> class.
        /// </summary>
        /// <param name="message">The error  message.</param>
        public NotInitializedException(string message)
            : base(message)
        { }
    }

    /// <summary>
    /// Class that represents synchronization exception.
    /// </summary>
    public class SynchronizationObjectException : Exception
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SynchronizationObjectException"/> class.
        /// </summary>
        /// <param name="message">The error message.</param>
        public SynchronizationObjectException(string message) : base(message) { }
    }

    /// <summary>
    /// Class that represents callback data.
    /// </summary>    
    public class CallbackData
    {
        /// <summary>
        /// Gets or sets the callback.
        /// </summary>
        /// <value>The callback.</value>
        public Delegate Callback { get; set; }
        /// <summary>
        /// Gets or sets the callback json preprocess.
        /// </summary>
        /// <value>The callback json preprocess.</value>
        public CallbackJsonPreprocess_Handler CallbackJsonPreprocess { get; set; }
    }

    /// <summary>
    /// Class that represents VK initialization failed event arguments.
    /// </summary>
    public class VkInitFailedEventArgs
    {
        /// <summary>
        /// Gets or sets the exception.
        /// </summary>
        /// <value>The exception.</value>
        public Exception Exception
        {
            get;
            protected set;
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="VkInitFailedEventArgs"/> class.
        /// </summary>
        /// <param name="ex">The exception.</param>
        public VkInitFailedEventArgs(Exception ex)
        {
            this.Exception = ex;
        }
    }
}
